/*
   CC.NET SideBar Gadget for Windows Vista 
   (C) Simone Chiaretta, 2007
   http://codeclimber.net.nz

   This project is licensed under the new BSD license.
   See the License.txt file for more information.
*/

var scrollStep=20;

function scrollUp(div)
{
   var prevTop=div.style.top;
   var prevTopNum=0;
   if(prevTop.length!=0)
      prevTopNum=prevTop.substring(0,prevTop.length-2);
   nextTop=prevTopNum-0+scrollStep;
   if(nextTop>0)
      nextTop=0;
   div.style.top = nextTop + "px";
}

function scrollDown(div)
{
   var prevTop=div.style.top;
   var prevTopNum=0;
   if(prevTop.length!=0)
      prevTopNum=prevTop.substring(0,prevTop.length-2);
   nextTop=prevTopNum-scrollStep;
   if(div.scrollHeight<div.parentNode.clientHeight)
      nextTop=0;
   else
   {
      if(nextTop<div.scrollTop-div.scrollHeight+div.parentNode.clientHeight-(scrollStep/2))
         nextTop=div.scrollTop-div.scrollHeight+div.parentNode.clientHeight-(scrollStep/2);
   }
   div.style.top = nextTop + "px";
}


function resetScrollPosition(div)
{
   div.style.top = "0px";
}